home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MEMORY.SWG / 0053_Compare areas of Memory.pas < prev    next >
Pascal/Delphi Source File  |  1994-05-26  |  2KB  |  65 lines

  1. {$R-,S-,V-}
  2. {
  3. **
  4. **  CompMem - A routine to compare to areas of memory for equality
  5. **  by Richard S. Sadowsky [74017,1670]
  6. **  version 1.0  5/11/88
  7. **  released to the public domain
  8. **  requires file MEMCOMP.OBJ to recompile
  9. **
  10.  
  11. }
  12. unit MemComp;
  13.  
  14. interface
  15.  
  16. function CompMem(var Block1,Block2; Size : Word) : Word;
  17. { returns 0 if Block1 and Block2 are equal for Size bytes, otherwise }
  18. { returns position of first non matching byte }
  19.  
  20. implementation
  21.  
  22. function CompMem(var Block1,Block2; Size : Word) : Word; External;
  23. {$L memcomp.Obj}
  24.  
  25. end.
  26.  
  27. { ---------------------   XX3402 CODE --------------------- }
  28. { cut this out and save as MEMCOMP.XX  execute :
  29. {    XX3402 D MEMCOMP.XX to create MEMCOMP.OBJ              }
  30.  
  31.  
  32.  
  33. *XX3402-000108-110588--72--85-20839-----MEMCOMP.OBJ--1-OF--1
  34. U+o+0qpZPKBjPL+iEJBBOtM5+++2Eox2FIGM-k+c7++0+E2FY+s+++25EoxBI2p3HE+++2m6
  35. -+++cU5Fc0U++E++WxmAqXD+BchD-CAHBgJr0XP2TkPwwuNo-XO9FkEfkMvOmUc+9sc0++-o
  36. ***** END OF BLOCK 1 *****
  37.  
  38. { -------------   TEST PROGRAM ---------------------  }
  39.  
  40. {$R-,S-}
  41. program CompTest;
  42. uses MemComp;
  43.  
  44. type
  45.   Tipe = array[1..128] of byte;
  46.  
  47. var
  48.   Var1,Var2 : Tipe;
  49.   I,CompRes : Word;
  50.  
  51. begin
  52.   FillChar(var2,SizeOf(Tipe),0); { init Var2 to all zeros }
  53.   for I := 1 to 128  do          { set var1 = 1 2 3 4 5 ... 128 }
  54.     Var1[I] := I;
  55.   CompRes := CompMem(Var1,Var2,128); { compare, should return first }
  56.                                      { byte as non match }
  57.   WriteLn('While not equal, CompMem = ',CompRes); { show results }
  58.   Var2 := Var1;                  { make them equal }
  59.   CompRes := CompMem(Var1,Var2,128); { test again, should return 0 }
  60.   WriteLn('While equal, CompMem = ',CompRes);
  61.   Var2[128] := 0;                    { make all equal except last byte }
  62.   CompRes := CompMem(Var1,Var2,128); { test again, should return 128 }
  63.   WriteLn('While not equal, CompMem = ',CompRes);
  64. end.
  65.